package com.ginage.gaugemanager.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {

	
	
	public static String dateToTimestamp(String s){
		SimpleDateFormat sdf=null;
		if(s.contains("-")) {
			sdf=new SimpleDateFormat("yyyy-MM-dd");
		}else if(s.contains("/")) {
			sdf=new SimpleDateFormat("yyyy/MM/dd");
		}else if(s.contains(":")) {
			sdf=new SimpleDateFormat("yyyy:MM:dd");
		}
		Date date = null;
		try {
			date = sdf.parse(s);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return date.getTime()+"";
		
	}
	
	public static String timestampToDate(String string) {
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		Date date=new Date(Long.valueOf(string));
		
		return sdf.format(date);
		
	}
	
}
